package com.smart.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.smart.model.Community;
import com.smart.util.DBUtil;

public class CommunityDAO {
   public List<Community> getCommunityList() throws SQLException
   {
	   List<Community> communityList=new ArrayList<>();
	   Connection conn = DBUtil.getConnection();
		String sql="select * from community";
		PreparedStatement pSt = conn.prepareCall(sql);
		ResultSet rs=pSt.executeQuery();
		while(rs.next())
		{
			Community community=new Community();
			community.setId(rs.getInt("id"));
			community.setName(rs.getString("name"));
			community.setProvince(rs.getString("province"));
			community.setCity("city");
			community.setZone("zone");
			community.setDetailed_address("detailed_address");
			communityList.add(community);
		}
		return communityList;
   }
}
